package com.pswv2.admin.user.imp;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pswv2.admin.user.service.AdminUserService;
import com.pswv2.bub.bsc.dao.po.AdminUser;
import com.pswv2.util.ExtraSpringHibernateTemplate;


@Service
public class AdminUserServiceImpl implements AdminUserService {
	private static Class<?> poc = AdminUser.class;
	@Autowired
	private ExtraSpringHibernateTemplate extraSpringHibernateTemplate;

	@Override
	public AdminUser queryByAccount(String account) {
		DetachedCriteria detached = DetachedCriteria.forClass(poc);
		detached.add(Restrictions.eq("account", account));
		return extraSpringHibernateTemplate.findFirstOneByCriteria(detached);
	}

	@Override
	public AdminUser queryById(Integer id) {
		return extraSpringHibernateTemplate.findFirstOneByPropEq(poc, "adminUserId", id);
	}
}
